<?php
 class Dt_access {
    public $CI;
    public function __construct(){
        $this->CI =& get_instance();
    }
    public function run(){
       $controller = $this->CI->router->class;
       $role = $this->CI->session->userdata('user_level');
       $this->CI->load->library('dt_auth');
       $dt_auth = new Dt_auth();
       $all_roles = $dt_auth->get_all_roles();
       $allow = false;//echo "\n$role\n$controller";
       foreach ($all_roles as $key => $val) { // print_r($val);
           if($role==$key && in_array($controller,$val)){
               $allow = true;
               break;
           }
       }
       //edit here
       if(!$allow){
           if($role=='guest'){
               redirect('login');
           }else {
               show_404();
           }
       }
    }
    }
?>
